package com.itheima.c_url;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * 1.完全匹配
 *     以 / 开头,匹配/后面的所有内容,必须完全匹配
 *     eg:
 * 				/demo1Servlet
 *         /abc/demo1Servlet
 * 2.目录匹配
 *     以 / 开头
 *     eg:
 * 			/aa/*
 * 			/*
 * 3.后缀名匹配
 * 	以 * 开头
 * 	eg:
 * 		*.abc
 * 		*.action
 * 		*.do
 * 4.缺省匹配(我们不能使用留个服务器和框架使用的)
 * 	 /  : 一般留给服务器使用,可以匹配一切资源
 *
 * 优先级:
 *  	完全匹配 > 目录匹配 > 后缀名匹配 > 缺省匹配
 */
//@WebServlet(urlPatterns = "/a")//完全匹配
//@WebServlet(urlPatterns = "/b/*")//目录匹配
@WebServlet(urlPatterns = "*.do")//后缀名匹配
public class UrlServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("UrlServlet方法执行了");
        response.getWriter().println("success");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
